home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 191_01 / spkrctl.c < prev    next >
Text File  |  1986-05-23  |  2KB  |  57 lines

  1.  
  2. /*  SPKRCTL.C                           Last update: 09 Feb 86  */
  3.  
  4. /* ------------------------------------------------------------ */
  5. /*      This is a portion of the SOUND EFFECTS LIBRARY.         */
  6. /*                                                              */
  7. /*      Copyright (C) 1986 by Paul Canniff.                     */
  8. /*      All rights reserved.                                    */
  9. /*                                                              */
  10. /*      This library has been placed into the public domain     */
  11. /*      by the author.  Use is granted for non-commercial       */
  12. /*      pusposes, or as an IMBEDDED PORTION of a commercial     */
  13. /*      product.                                                */
  14. /*                                                              */
  15. /*      Paul Canniff                                            */
  16. /*      PO Box 1056                                             */
  17. /*      Marlton, NJ 08053                                       */
  18. /*                                                              */
  19. /*      CompuServe ID: 73047,3715                               */
  20. /*                                                              */
  21. /* ------------------------------------------------------------ */
  22.  
  23.  
  24. #include <stdio.h>
  25. #include "sound.h"
  26.  
  27.  
  28. void spkr_cntr(n)
  29. unsigned n;
  30. {
  31.     unsigned lo_byte, hi_byte;
  32.  
  33.     lo_byte = n & 0xff;
  34.     hi_byte = (n >> 8) & 0xff;
  35.  
  36.     outp(SPKTMR+1,182);
  37.     outp(SPKTMR,lo_byte);
  38.     outp(SPKTMR,hi_byte);
  39. }
  40.  
  41. void spkr_freq(f)
  42. long f;
  43. {
  44.     spkr_cntr(FREQ2CTR(f));
  45. }
  46.  
  47. void spkr_on()
  48. {
  49.     outp(KBCTL,inp(KBCTL)|0x3);
  50. }
  51.  
  52. void spkr_off()
  53. {
  54.     outp(KBCTL,inp(KBCTL)&0xfc);
  55. }
  56.  
  57.